   import "../style/pay.css"
    import conf from '../config/userconf.js'
  export default {
    data() {
      return {
          list:[],
          searchData:{
                c_area_id:'',
                c_secondary_area:'',
                c_room:'',
                c_trading_type:'',
                c_buy_status:'',
                c_use_type:'',
                date_type:'',
                start_time:'',
                end_time:'',
                c_room_type:'',
                c_toward:'',
                c_price_min:'',
                c_price_max:'',
                c_acreage_max:'',
                c_acreage_min:'',
                c_customers_type:'',
                c_store_id:'',
                c_employees_id:'',
                keywords:''
          },
          form:{
              name:'',
              region:''
          },
          rules:{
            name: [
                { required: true, message: '请输入姓名', trigger: 'blur' }
            ],
            region: [
                { required: true, message: '请选择区域', trigger: 'change' }
            ],
          },
          multipleSelection: [],
          dialogtitle:'新增',
          Timef:true,
          centerDialogVisible:false
      }
    },
    methods: {
        /* 列表*/
        getList (data=null){
            conf.resources.list(data,(state,res)=>{
                if (state == 'success'&&res.data.state == 0){
                    this.list = res.data.data
                    
                }
            })
        },
        /*查询 */
        search () {
            let data  = this.searchData;
            data.start_time = this.transTime(data.start_time)
            data.end_time = this.transTime(data.end_time)

            this.getList(data)
        },
        /* 时间转化 */
        transTime (val) {
            let time = val? Date.parse(new Date(val)):''
            return  time
        },
        /*取消 */
        cancel (formName) {
            this.centerDialogVisible = false;
            this.$refs[formName].resetFields()
        },
        /*提交 */
        submit (formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.judgeprimise();
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        /*判断提交 */
        judgeprimise () {
            if (this.dialogtitle == '新增') {
                conf.resources.add(this.form,(state,res)=>{
                    if (state == 'success'&&res.state == 0){
                        this.getList()
                        this.centerDialogVisible = false
                    }
                })
            }else {
                conf.resources.edit(this.form,(state,res)=>{
                    if (state == 'success'&&res.state == 0){
                        this.getList()
                    }
                })
            }
        },
        /*增 */
        add (formName) {
            this.centerDialogVisible = true;
        },
        /*选择 */
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        /*删 */
        del () {
            let data = this.multipleSelection
            conf.resources.del(data,(state,res)=>{
                if (state == 'success'&&res.data.state == 0){
                    this.getList()
                }
            })
        },
        deltest (index,rows) {
            rows.splice(index, 1)
        },
        /**改*/
        edit (val) {
            this.form = val
            this.centerDialogVisible = true;

        },
        /*时间选择显示控件 */
        Timecontrol (val) {
            if(val) {
                this.Timef = false
            }
        }
    },
    mounted (){
        this.$nextTick(function(){
            this.getList()
        })
    },
        
  }